<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>v-once指令学习</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript">
      Vue.config.productionTip = false;
    </script>
  </head>
  <body>
    <div id="root">
      <!-- v-once在初次渲染之后，就视为静态内容了，不再变动，可优化性能 -->
      <h2 v-once>初始化的值:{{n}}</h2>
      <h2>当前的n值是:{{n}}</h2>
      <button @click="n++">点我n+1</button>
    </div>
  </body>

  <script type="text/javascript">
    const vm = new Vue({
      el: "#root",
      data: {
        //假设这里是后端返回，或复杂计算结果
        n: 1,
      },
    });
  </script>
</html>
